<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

/*
 * HTML encode special characters Helper
 *
 * @access	public
 * @param	string
 * @return	string	HTML encoded string
 *
 */
function to_entities($string)
{
	$CI =& get_instance();
	return htmlentities($string, ENT_QUOTES, $CI->config->item('charset'));
}

function endcodevntoasc( $string )
{
	$vnchar = array(
			' '=>'000',
			'0'=>'001',
			'1'=>'002',
			'2'=>'003',
			'3'=>'004',
			'4'=>'005',
			'5'=>'006',
			'6'=>'007',
			'7'=>'008',
			'8'=>'009',
			'9'=>'010',
			'a'=>'011',
			'A'=>'012',
			'à'=>'013',
			'À'=>'014',
			'ả'=>'015',
			'Ả'=>'016',
			'ã'=>'017',
			'Ã'=>'018',
			'á'=>'019',
			'Á'=>'020',
			'ạ'=>'021',
			'Ạ'=>'022',
			'ă'=>'023',
			'Ă'=>'024',
			'ằ'=>'025',
			'Ằ'=>'026',
			'ẳ'=>'027',
			'Ẳ'=>'028',
			'ẵ'=>'029',
			'Ẵ'=>'030',
			'ắ'=>'031',
			'Ắ'=>'032',
			'ặ'=>'033',
			'Ặ'=>'034',
			'â'=>'035',
			'Â'=>'036',
			'ầ'=>'037',
			'Ầ'=>'038',
			'ẩ'=>'039',
			'Ẩ'=>'040',
			'ẫ'=>'041',
			'Ẫ'=>'042',
			'ấ'=>'043',
			'Ấ'=>'044',
			'ậ'=>'045',
			'Ậ'=>'046',
			'b'=>'047',
			'B'=>'048',
			'c'=>'049',
			'C'=>'050',
			'd'=>'051',
			'D'=>'052',
			'đ'=>'053',
			'Đ'=>'054',
			'e'=>'055',
			'E'=>'056',
			'è'=>'057',
			'È'=>'058',
			'ẻ'=>'059',
			'Ẻ'=>'060',
			'ẽ'=>'061',
			'Ẽ'=>'062',
			'é'=>'063',
			'É'=>'064',
			'ẹ'=>'065',
			'Ẹ'=>'066',
			'ê'=>'067',
			'Ê'=>'068',
			'ề'=>'069',
			'Ề'=>'070',
			'ể'=>'071',
			'Ể'=>'072',
			'ễ'=>'073',
			'Ễ'=>'074',
			'ế'=>'075',
			'Ế'=>'076',
			'ệ'=>'077',
			'Ệ'=>'078',
			'f'=>'079',
			'F'=>'080',
			'g'=>'081',
			'G'=>'082',
			'h'=>'083',
			'H'=>'084',
			'i'=>'085',
			'I'=>'086',
			'ì'=>'087',
			'Ì'=>'088',
			'ỉ'=>'089',
			'Ỉ'=>'090',
			'ĩ'=>'091',
			'Ĩ'=>'092',
			'í'=>'093',
			'Í'=>'094',
			'ị'=>'095',
			'Ị'=>'096',
			'j'=>'097',
			'J'=>'098',
			'k'=>'099',
			'K'=>'100',
			'l'=>'101',
			'L'=>'102',
			'm'=>'103',
			'M'=>'104',
			'n'=>'105',
			'N'=>'106',
			'o'=>'107',
			'O'=>'108',
			'ò'=>'109',
			'Ò'=>'110',
			'ỏ'=>'111',
			'Ỏ'=>'113',
			'õ'=>'113',
			'Õ'=>'114',
			'ó'=>'115',
			'Ó'=>'116',
			'ọ'=>'117',
			'Ọ'=>'118',
			'ô'=>'119',
			'Ô'=>'120',
			'ồ'=>'121',
			'Ồ'=>'122',
			'ổ'=>'123',
			'Ổ'=>'124',
			'ỗ'=>'125',
			'Ỗ'=>'126',
			'ố'=>'127',
			'Ố'=>'128',
			'ộ'=>'129',
			'Ộ'=>'130',
			'ơ'=>'131',
			'Ơ'=>'132',
			'ờ'=>'133',
			'Ờ'=>'134',
			'ở'=>'135',
			'Ở'=>'136',
			'ỡ'=>'137',
			'Ỡ'=>'138',
			'ớ'=>'139',
			'Ớ'=>'140',
			'ợ'=>'141',
			'Ợ'=>'142',
			'p'=>'143',
			'P'=>'144',
			'q'=>'145',
			'Q'=>'146',
			'r'=>'147',
			'R'=>'148',
			's'=>'149',
			'S'=>'150',
			't'=>'151',
			'T'=>'152',
			'u'=>'153',
			'U'=>'154',
			'ù'=>'155',
			'Ù'=>'156',
			'ủ'=>'157',
			'Ủ'=>'158',
			'ũ'=>'159',
			'Ũ'=>'160',
			'ú'=>'161',
			'Ú'=>'162',
			'ụ'=>'163',
			'Ụ'=>'164',
			'ư'=>'165',
			'Ư'=>'166',
			'ừ'=>'167',
			'Ừ'=>'168',
			'ử'=>'169',
			'Ử'=>'170',
			'ữ'=>'171',
			'Ữ'=>'172',
			'ứ'=>'173',
			'Ứ'=>'174',
			'ự'=>'175',
			'Ự'=>'176',
			'v'=>'177',
			'V'=>'178',
			'w'=>'179',
			'W'=>'180',
			'x'=>'181',
			'X'=>'182',
			'y'=>'183',
			'Y'=>'184',
			'ỳ'=>'185',
			'Ỳ'=>'186',
			'ỷ'=>'187',
			'Ỷ'=>'188',
			'ỹ'=>'189',
			'Ỹ'=>'190',
			'ý'=>'191',
			'Ý'=>'192',
			'ỵ'=>'193',
			'Ỵ'=>'194',
			'z'=>'195',
			'Z'=>'196'
	);
	$arr1 = mb_str_split($string);
	$str = '';
	//var_dump($arr1);
	foreach($arr1 as $char)
	{
		//echo $char;
		$str = $str. $vnchar[$char];
	}
	return $str;
}
function mb_str_split( $string ) {
	# Split at all position not after the start: ^
	# and not before the end: $
	return preg_split('/(?<!^)(?!$)/u', $string );
}
/* End of file MY_string_helper.php */
/* Location: ./application/helpers/MY_string_helper.php */